# 创建表 catalog
CREATE TABLE IF NOT EXISTS `t_${productID}_catalog` (
  `id` varchar(32) NOT NULL,
  `describing` varchar(100),
  `name` varchar(50) NOT NULL,
  `parentCatalogID` varchar(32) NOT NULL,
  `sequence` varchar(5),
  `version_id` varchar(32) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `parentCatalogID` (`parentCatalogID`),
  KEY `FK${productID}a` (`version_id`),
  CONSTRAINT `FK${productID}a` FOREIGN KEY (`version_id`) REFERENCES `t_version` (`id`)
);
GO

# 创建表 test_case
CREATE TABLE IF NOT EXISTS `t_${productID}_test_case` (
  `id` varchar(32) NOT NULL,
  `catalogID` varchar(32) NOT NULL,
  `describing` varchar(150) NOT NULL,
  `editDate` datetime NOT NULL,
  `exResult` longtext,
  `premiss` varchar(150),
  `remark` varchar(150),
  `sequence` varchar(5),
  `steps` longtext,
  `user_id` varchar(32) NOT NULL,
  `version_id` varchar(32) NOT NULL,
  `caseState_id` varchar(32),
  PRIMARY KEY (`id`),
  KEY `catalogID` (`catalogID`),
  KEY `FK${productID}b` (`version_id`),
  KEY `FK${productID}c` (`user_id`),
  KEY `FK${productID}d` (`caseState_id`),
  CONSTRAINT `FK${productID}b` FOREIGN KEY (`version_id`) REFERENCES `t_version` (`id`),
  CONSTRAINT `FK${productID}c` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`),
  CONSTRAINT `FK${productID}d` FOREIGN KEY (`caseState_id`) REFERENCES `t_case_state` (`id`)
);
GO

# 创建表 test_case_history
CREATE TABLE IF NOT EXISTS `t_${productID}_test_case_history` (
  `id` varchar(32) NOT NULL,
  `catalogID` varchar(32) NOT NULL,
  `describing` varchar(150) NOT NULL,
  `editDate` datetime NOT NULL,
  `exResult` longtext,
  `premiss` varchar(150),
  `remark` varchar(150),
  `sequence` varchar(5),
  `steps` longtext,
  `testCaseID` varchar(32) NOT NULL,
  `caseState_id` varchar(32),
  `user_id` varchar(32) NOT NULL,
  `version_id` varchar(32) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `testCaseID` (`testCaseID`),
  KEY `catalogID` (`catalogID`),
  KEY `FK${productID}e` (`version_id`),
  KEY `FK${productID}f` (`user_id`),
  KEY `FK${productID}g` (`caseState_id`),
  CONSTRAINT `FK${productID}e` FOREIGN KEY (`version_id`) REFERENCES `t_version` (`id`),
  CONSTRAINT `FK${productID}f` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`),
  CONSTRAINT `FK${productID}g` FOREIGN KEY (`caseState_id`) REFERENCES `t_case_state` (`id`)
);
GO

# 创建表 test_case_modify_note
CREATE TABLE IF NOT EXISTS `t_${productID}_test_case_modify_note` (
  `id` varchar(32) NOT NULL,
  `modifyDate` datetime NOT NULL,
  `reason` varchar(50),
  `testCaseID` varchar(32) NOT NULL,
  `user_id` varchar(32) NOT NULL,
  `version_id` varchar(32) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK${productID}h` (`version_id`),
  KEY `FK${productID}i` (`user_id`),
  CONSTRAINT `FK${productID}h` FOREIGN KEY (`version_id`) REFERENCES `t_version` (`id`),
  CONSTRAINT `FK${productID}i` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`)
);
GO

# 创建表 test_plan
CREATE TABLE IF NOT EXISTS `t_${productID}_test_plan` (
  `id` varchar(32) NOT NULL,
  `closed` bit NOT NULL,
  `createDate` datetime NOT NULL,
  `describing` varchar(100),
  `name` varchar(50) NOT NULL,
  `version_id` varchar(32) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK${productID}j` (`version_id`),
  CONSTRAINT `FK${productID}j` FOREIGN KEY (`version_id`) REFERENCES `t_version` (`id`)
);
GO

# 创建表 test_case_executant
CREATE TABLE IF NOT EXISTS `t_${productID}_test_case_executant` (
  `id` varchar(32) NOT NULL,
  `testCaseID` varchar(32) NOT NULL,
  `testPlanID` varchar(32) NOT NULL,
  `user_id` varchar(32) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `testPlanID` (`testPlanID`),
  KEY `FK${productID}k` (`user_id`),
  CONSTRAINT `FK${productID}k` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`)
);
GO

# 创建表 test_result
CREATE TABLE IF NOT EXISTS `t_${productID}_test_result` (
  `id` varchar(32) NOT NULL,
  `actualResult` longtext,
  `bugNO` varchar(6),
  `exEndTime` datetime NOT NULL,
  `exStartTime` datetime NOT NULL,
  `exTime` integer NOT NULL,
  `testCaseID` varchar(32) NOT NULL,
  `testPlanID` varchar(32) NOT NULL,
  `version_id` varchar(32) NOT NULL,
  `executeState_id` varchar(32) NOT NULL,
  `user_id` varchar(32) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK${productID}l` (`version_id`),
  KEY `FK${productID}m` (`user_id`),
  KEY `FK${productID}n` (`executeState_id`),
  CONSTRAINT `FK${productID}l` FOREIGN KEY (`version_id`) REFERENCES `t_version` (`id`),
  CONSTRAINT `FK${productID}m` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`),
  CONSTRAINT `FK${productID}n` FOREIGN KEY (`executeState_id`) REFERENCES `t_execute_state` (`id`)
);
GO
